//
import Bus from "./Bus";
const A3 = () => {
  let _data = null;
  const setState = ({ target }) => {
    const { name } = target;
    if (name) {
      _data.setTheme(target.name);
    } else {
      alert("没有颜色值");
    }
  };
  return (
    <Bus.Consumer>
      {/* 必须是个函数 */}
      {(data) => {
        _data = data;
        return (
          <div style={{ color: data.theme }}>
            <button name="blue" onClick={setState}>
              蓝
            </button>
            <button name="yellow" onClick={setState}>
              黄
            </button>
            <button name="green" onClick={setState}>
              绿
            </button>
            <p>要放假喽</p>
          </div>
        );
      }}
    </Bus.Consumer>
  );
};

export default A3;
